#pragma once
#include"hashTable.h"

template<class K, class V, class hashFunc = hashFunc<K>>
class unordered_map
{
	struct MapOfT
	{
		const K& operator()(const pair<K, V>& kv)
		{
			return kv.first;
		}
	};
	typedef hashBucket<K, pair<K,V>, MapOfT, hashFunc> hashBucket;
private:
	hashBucket _hb;
public:
	typedef typename hashBucket::iterator iterator;
	iterator begin(){ return _hb.begin(); }
	iterator end(){ return _hb.end(); }
	
	pair<iterator, bool> insert(const pair<K,V>& kv)
	{
		return _hb.insert(kv);
	}
	bool erase(const K& k)
	{
		return _hb.erase(k);
	}
	iterator find(const K& k)
	{
		return _hb.find(k);
	}
	V& operator[](const K& k)
	{
		pair<iterator, bool> p = insert(make_pair(k, V()));
		return p.first->second;
	}
};